define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope, Newpropromotions_info, $ionicSlideBoxDelegate, $stateParams,$sce) {
		
		$scope.goods_id = $stateParams.goods_id;
		$scope.act_id = $stateParams.act_id;
		$scope.slideIndex = $stateParams.index;
//		if($scope.slideIndex==1){
//			$scope.selectTab = 1;
//		}else{
//			$scope.selectTab = 0;
//		}
		$scope.init_data = function() {
			Newpropromotions_info.get_description($scope.goods_id,$scope.act_id, function(data) {
				$scope.detail = data.result;
				$scope.description = $sce.trustAsHtml(data.result.description);
			});
		}
		$scope.$on('$ionicView.beforeEnter',function(){
			$scope.init_data(); //必须在定义之后
		});
		$scope.$on('$ionicView.afterEnter', function() {
			//滑动切换
			if($scope.slideIndex != undefined) {
			$scope.selectTab = $scope.slideIndex;
		};
		$ionicSlideBoxDelegate.$getByHandle('tab-handle').slide($scope.selectTab);
		}, false);
		$scope.activeTab = function(index) {
			$scope.selectTab = index;
			$ionicSlideBoxDelegate.$getByHandle('tab-handle').slide(index);
		};
		//滑动切换
		$scope.slideChanged = function(index) {
			console.log(index);
			$scope.selectTab = index;
		};
		//加载数据
		
		

	}

	controller.$inject = ['$scope', 'Newpropromotions_info', '$ionicSlideBoxDelegate', '$stateParams','$sce'];

	return app.registerController("newpropromotions_infoctrl",controller);
});